//
//  KeHuListTableViewCell.m
//  EnterpriseEdition
//
//  Created by ypj on 2021/10/9.
//

#import "KeHuListTableViewCell.h"
#import "KeHuInfoModel.h"
@implementation KeHuListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.customerTypeLab setCornerRadius:2];
    
    UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(lpGR:)];
    [self addGestureRecognizer:longPressGR];
    
    
}

-(void)lpGR:(UILongPressGestureRecognizer *)lpGR {

    if (self.isDelete) {
        if (lpGR.state == UIGestureRecognizerStateBegan) {//手势开始
            if (self.toSend) {
                self.toSend();
            }
        }
    }

}
// 全部客户
- (void)setAllModel:(KeHuInfoModel *)allModel{
    _allModel = allModel;
    
    self.messageLb.text = allModel.customerName;
    NSString *str = allModel.customerPhone;
//    if (!StringIsEmpty(allModel.customerPhone)&&allModel.customerPhone.length > 3) {
//        NSString *str = [allModel.customerName substringToIndex:3];
//        str = [str stringByAppendingString:@"********"];
//    }
    self.phonelb.text =  str;
    self.customerTypeLab.hidden = NO;
    self.customerTypeLabCons.constant = 40;
    if (allModel.isRegister) {
        self.customerTypeLab.text = @"已注册";
        self.customerTypeLab.textColor = ColorWith3C6CFC;
        self.customerTypeLab.backgroundColor = [ColorWith3C6CFC colorWithAlphaComponent:0.1];
    }
    else  {
        self.customerTypeLab.text = @"未注册";
        self.customerTypeLab.textColor = ColorWithEA545A;
        self.customerTypeLab.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
    }
}
- (void)setNotSignModel:(KeHuInfoModel *)notSignModel{
    _notSignModel = notSignModel;
    self.messageLb.text = notSignModel.customerName;
    self.phonelb.text = notSignModel.customerPhone;
    self.phonelb.textColor = Color333;
    self.customerTypeLab.hidden = NO;
    self.customerTypeLab.text = @"未签约";
    self.customerTypeLabCons.constant = 38;
}
- (void)setSignedModel:(KeHuInfoModel *)signedModel{
    _signedModel = signedModel;
    
    self.messageLb.text = signedModel.customerName;
    self.phonelb.text = signedModel.customerPhone;
    
    self.carPayTypeLb.hidden = NO;
    if(signedModel.signState == 1){
        self.carPayTypeLb.text = @"签约中";
        self.carPayTypeLb.textColor = ColorWithFF921C;
        self.carPayTypeLb.backgroundColor = [ColorWithFF921C colorWithAlphaComponent:0.1];
        if([signedModel.leftPeriods intValue]==0){
            self.dayTimeLab.text = @"租期剩余  1天";
        }
        else {
            self.dayTimeLab.text = [NSString stringWithFormat:@"租期剩余  %@天",signedModel.leftPeriods];
        }
        [self.dayTimeLab addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"租期剩余"];

    }
    else if(signedModel.signState == 2){
   
        self.carPayTypeLb.text = @"已逾期";
        self.carPayTypeLb.textColor = ColorWithEA545A;
        self.carPayTypeLb.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
        self.dayTimeLab.text = [NSString stringWithFormat:@"已逾期  %@天",signedModel.leftPeriods];
        [self.dayTimeLab addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"已逾期"];

    }
    
    
    self.statusLabCons.constant = 40;
    
    
    self.carNumLb.text = [NSString stringWithFormat:@"车牌车型  %@ / %@",signedModel.carNum,signedModel.carBrand];
    [self.carNumLb addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"车牌车型"];
    self.rentLab.text = [NSString stringWithFormat:@"月租金  %@",[NSString toTen:signedModel.rent]];
    [self.rentLab addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"月租金"];
    self.remarkLab.text = [NSString stringWithFormat:@"备注信息  %@",[NSString stringWithNull:signedModel.contractRemark]];
    [self.remarkLab addAttributes:TextAttrCorlor(ColorWithAAAAAA) forString:@"备注信息"];

   
   

}
@end
